package com.commerceerp.system.controller;


import com.commerceerp.system.entity.*;
import com.commerceerp.system.service.*;
import com.commerceerp.system.util.ApiResult;
import com.commerceerp.system.util.DateUtil;
import com.commerceerp.system.util.RdPage;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Api(description = "分销接口", value = "分销接口")
@Scope("prototype")
@RestController
@EnableAutoConfiguration
public class FxOrderController {

    @Autowired
    private FxUserService fxUserService;

    @Autowired
    private FxRoleInfoService fxRoleInfoService;

    @Autowired
    private FxClassLevelService fxClassLevelService;

    @Autowired
    private FxGoodInfoService fxGoodInfoService;

    @Autowired
    private FxOrderInfoService fxOrderInfoService;

    @Autowired
    private FxReceiveInfoService fxReceiveInfoService;

    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "分销商户申请列表")
    @ApiImplicitParams({
    })
    @RequestMapping(value = "/getFxApplyAccountByLoginUser", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxApplyAccountByLoginUser(HttpServletRequest request) throws IOException {

        ApiResult result = null;

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }

        List<FxUserInfo> list = this.fxUserService.getFxApplyAccountByLoginUser((String) to.getData());

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE,"查询成功",list,null);

        return result;
    }

    @ApiOperation(value = "查询单个分销商户信息")
    @ApiImplicitParams({
    })
    @RequestMapping(value = "/getFxUserInfoByUserId", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxUserInfoByUserId(HttpServletRequest request) throws IOException {

        ApiResult result = null;

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }
        FxUserInfo fxUserInfo = this.fxUserService.getFxUserInfoByUserId((String) to.getData());

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE,"查询成功",fxUserInfo,null);

        return result;
    }


    @ApiOperation(value = "新增分销商户")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "userName", value = "分销账号昵称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "userRealName", value = "真实姓名", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "userIdcardNumber", value = "身份证号", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "country", value = "国家", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "postcode", value = "邮编", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "address", value = "默认收货地址", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "userSexy", value = "用户性别", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "userPhone", value = "用户联系号码", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "companyName", value = "公司名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "companyYyzzhNum", value = "营业执照号", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "companyYyzzhPic1", value = "营业执照号照片1", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "companyYyzzhPic2", value = "营业执照号照片2", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "qqfrName", value = "企业法人姓名", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "qqfrPhone", value = "法人联系电话", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "qqfrIdcardZmpic", value = "法人身份证正面", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "qqfrIdcardFmpic", value = "法人身份证反面", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "qqfrIdcardNum", value = "法人身份证号码", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "companyAddress", value = "企业地址", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "remark", value = "备注", required = false, dataType = "String")
    })
    @RequestMapping(value = "/addFxUserInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult addFxUserInfo( @RequestParam(value = "userName", required = false) String userName,
                                    @RequestParam(value = "userRealName", required = false) String userRealName,
                                    @RequestParam(value = "userIdcardNumber", required = false) String userIdcardNumber,
                                    @RequestParam(value = "userSexy", required = false) String userSexy,
                                    @RequestParam(value = "userPhone", required = false) String userPhone,
                                    @RequestParam(value = "companyName", required = false) String companyName,
                                    @RequestParam(value = "companyYyzzhNum", required = false) String companyYyzzhNum,
                                    @RequestParam(value = "companyYyzzhPic1", required = false) String companyYyzzhPic1,
                                    @RequestParam(value = "companyYyzzhPic2", required = false) String companyYyzzhPic2,
                                    @RequestParam(value = "qqfrName", required = false) String qqfrName,
                                    @RequestParam(value = "qqfrPhone", required = false) String qqfrPhone,
                                    @RequestParam(value = "qqfrIdcardZmpic", required = false) String qqfrIdcardZmpic,
                                    @RequestParam(value = "qqfrIdcardFmpic", required = false) String qqfrIdcardFmpic,
                                    @RequestParam(value = "qqfrIdcardNum", required = false) String qqfrIdcardNum,
                                    @RequestParam(value = "companyAddress", required = false) String companyAddress,
                                    @RequestParam(value = "remark", required = false) String remark,
                                    @RequestParam(value = "country", required = false) String country,
                                    @RequestParam(value = "postcode", required = false) String postcode,
                                    @RequestParam(value = "address", required = false) String address,
                                    HttpServletRequest request
                                    ) throws IOException {

        ApiResult result = null;

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }

        FxUserInfo fxUserInfo = new FxUserInfo();
        fxUserInfo.setCompanyAddress(companyAddress);
        fxUserInfo.setCompanyName(companyName);
        fxUserInfo.setCompanyYyzzhNum(companyYyzzhNum);
        fxUserInfo.setCompanyYyzzhPic1(companyYyzzhPic1);
        fxUserInfo.setCompanyYyzzhPic2(companyYyzzhPic2);
        fxUserInfo.setCompanyAddress(companyAddress);
        fxUserInfo.setLoginUserId((String)to.getData());
        fxUserInfo.setQqfrIdcardFmpic(qqfrIdcardFmpic);
        fxUserInfo.setQqfrIdcardZmpic(qqfrIdcardZmpic);
        fxUserInfo.setUserIdcardNumber(userIdcardNumber);
        fxUserInfo.setQqfrName(qqfrName);
        fxUserInfo.setQqfrPhone(qqfrPhone);
        fxUserInfo.setRemark(remark);
        fxUserInfo.setUserName(userName);
        fxUserInfo.setUserRealName(userRealName);
        fxUserInfo.setUserPhone(userPhone);
        fxUserInfo.setUserSexy(userSexy);
        fxUserInfo.setCountry(country);
        fxUserInfo.setPostcode(postcode);
        fxUserInfo.setAddress(address);
        fxUserInfo.setUserPassward("12345");



        Integer success = this.fxUserService.addFxUserInfo(fxUserInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "分销商户审核申请列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "userAccountState", value = "申请账号状态(1:待审核，2:已审核，3;驳回)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "endTime", value = "截止时间", required = false, dataType = "String")
    })
    @RequestMapping(value = "/getFxApplyUserInfoToAudting", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxApplyUserInfoToAudting( @RequestParam(value = "userAccountState", required = false) String userAccountState,
                                                   @RequestParam(value = "beginTime", required = false) String beginTime,
                                                   @RequestParam(value = "endTime", required = false) String endTime) throws IOException {

        ApiResult result = null;



        List<FxUserInfo> list = this.fxUserService.getFxApplyUserInfoToAudting(userAccountState,beginTime,endTime);

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE,"查询成功",list,null);

        return result;
    }


    @ApiOperation(value = "审核分销商户通过或驳回")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "userId", value = "账号id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "操作类型(1:通过,2:驳回)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "cancelReason", value = "驳回原因", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/updateFxUserAccountToPassOrCancel", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updateFxUserAccountToPassOrCancel( @RequestParam(value = "userId", required = false) String userId,
                                    @RequestParam(value = "type", required = false) String type,
                                    @RequestParam(value = "cancelReason", required = false) String cancelReason) throws IOException {

        ApiResult result = null;



        FxUserInfo fxUserInfo = new FxUserInfo();
        fxUserInfo.setUserId(Integer.parseInt(userId));
        if("1".equals(type)){
            fxUserInfo.setUserAccountState("2");
        }else if("2".equals(type)){
            fxUserInfo.setUserAccountState("3");
            fxUserInfo.setUserCancelReason(cancelReason);
            fxUserInfo.setRemark("申请驳回原因:"+cancelReason);
        }

        Integer success = this.fxUserService.updateFxUserInfo(fxUserInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "新增用户角色信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roleName", value = "角色名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleDesc", value = "角色描述", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleMenuId", value = "角色菜单", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/addRoleInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult addRoleInfo( @RequestParam(value = "roleName", required = false) String roleName,
                                  @RequestParam(value = "roleDesc", required = false) String roleDesc,
                                  @RequestParam(value = "roleMenuId", required = false) String roleMenuId) throws IOException {

        ApiResult result = null;

        FxRoleInfo fxRoleInfo = new FxRoleInfo();
        fxRoleInfo.setRoleDesc(roleDesc);
        fxRoleInfo.setRoleMenuId(roleMenuId);
        fxRoleInfo.setRoleName(roleName);

        Integer success = this.fxRoleInfoService.addRoleInfo(fxRoleInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "编辑用户角色信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roleId", value = "角色id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleName", value = "角色名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleDesc", value = "角色描述", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleMenuId", value = "角色菜单", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleState", value = "角色状态(1:启用，2:禁用)", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/updateRoleInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updateRoleInfo( @RequestParam(value = "roleId", required = false) String roleId,
                                     @RequestParam(value = "roleName", required = false) String roleName,
                                     @RequestParam(value = "roleDesc", required = false) String roleDesc,
                                     @RequestParam(value = "roleMenuId", required = false) String roleMenuId,
                                     @RequestParam(value = "roleState", required = false) String roleState) throws IOException {

        ApiResult result = null;

        FxRoleInfo fxRoleInfo = new FxRoleInfo();
        fxRoleInfo.setRoleDesc(roleDesc);
        fxRoleInfo.setRoleMenuId(roleMenuId);
        fxRoleInfo.setRoleName(roleName);
        fxRoleInfo.setRoleState(roleState);
        fxRoleInfo.setRoleId(Integer.parseInt(roleId));
        fxRoleInfo.setRoleUpdateTime(DateUtil.getYMDHMSDate());

        Integer success = this.fxRoleInfoService.updateRoleInfo(fxRoleInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }

    @ApiOperation(value = "删除用户角色信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roleId", value = "角色id", required = false, dataType = "String")

    })
    @RequestMapping(value = "/deleteRoleInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult deleteRoleInfo( @RequestParam(value = "roleId", required = false) String roleId) throws IOException {

        ApiResult result = null;

        Integer success = this.fxRoleInfoService.deleteRoleInfo(roleId);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }

    @ApiOperation(value = "查询用户角色信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roleName", value = "角色名称", required = false, dataType = "String")
    })
    @RequestMapping(value = "/getAllRoleInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllRoleInfo(@RequestParam(value = "roleName", required = false) String roleName) throws IOException {

        List<FxRoleInfo> list = this.fxRoleInfoService.getAllRoleInfo(roleName);

        return  new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, null);

    }

    @ApiOperation(value = "一级类型菜单操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "oneLevelName", value = "一级菜单名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "oneLevelSort", value = "一级菜单排序", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "oneLevelId", value = "一级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "操作类型(1:添加,2:编辑,3:查询,4:删除)", required = false, dataType = "String")

    })
    @RequestMapping(value = "/handleOneLevelMenu", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult handleOneLevelMenu( @RequestParam(value = "oneLevelName", required = false) String oneLevelName,
                                         @RequestParam(value = "oneLevelSort", required = false) String oneLevelSort,
                                         @RequestParam(value = "oneLevelId", required = false) String oneLevelId,
                                         @RequestParam(value = "type", required = false) String type) throws IOException {

        ApiResult result = null;
        Integer success = null;
        List<Map> list = null;

        if("1".equals(type)){

            success = this.fxClassLevelService.addOneLevelMenu(oneLevelName,oneLevelSort);

        }else if("2".equals(type)){

            success = this.fxClassLevelService.updateOneLevelMenu(oneLevelName,oneLevelSort,oneLevelId);

        }else if("3".equals(type)){

            list = this.fxClassLevelService.getAllOneLevelMenu();

            return  new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, null);

        }else if("4".equals(type)){

            success = this.fxClassLevelService.delteOneLevelMenu(oneLevelId);

        }

        if (success == 1 ) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        }else{
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }

    @ApiOperation(value = "二级类型菜单操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "twoLevelName", value = "二级菜单名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "twoLevelSort", value = "二级菜单排序", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "oneLevelId", value = "一级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "twoLevelId", value = "一级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "commision", value = "佣金费率", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "操作类型(1:添加,2:编辑,3:查询,4:删除)", required = false, dataType = "String")

    })
    @RequestMapping(value = "/handleTwoLevelMenu", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult handleTwoLevelMenu( @RequestParam(value = "twoLevelName", required = false) String oneLevelName,
                                         @RequestParam(value = "twoLevelSort", required = false) String oneLevelSort,
                                         @RequestParam(value = "oneLevelId", required = false) String oneLevelId,
                                         @RequestParam(value = "twoLevelId", required = false) String twoLevelId,
                                         @RequestParam(value = "commision", required = false) String commision,
                                         @RequestParam(value = "type", required = false) String type) throws IOException {

        ApiResult result = null;
        Integer success = null;
        List<Map> list = null;

        if("1".equals(type)){

            success = this.fxClassLevelService.addTwoLevelMenu(oneLevelName,oneLevelSort,oneLevelId,commision);

        }else if("2".equals(type)){

            success = this.fxClassLevelService.updateTwoLevelMenu(oneLevelName,oneLevelSort,oneLevelId,commision,twoLevelId);

        }else if("3".equals(type)){

            list = this.fxClassLevelService.getAllTwoLevelMenu(oneLevelId);
            return  new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, null);

        }else if("4".equals(type)){

            success = this.fxClassLevelService.delteTwoLevelMenu(twoLevelId);

        }

        if (success == 1 ) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        }else{
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "添加分销商品")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "oneLevelId", value = "一级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "twoLevelId", value = "二级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodName", value = "商品名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPrice", value = "商品价格", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodColorStock", value = "商品颜色和库存,(如红色_1000,黑色_200)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPic", value = "商品图片，如:(a,b,c)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodDesc", value = "商品描述", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/addFxGoodInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult addFxGoodInfo( @RequestParam(value = "oneLevelId", required = false) String oneLevelId,
                                    @RequestParam(value = "twoLevelId", required = false) String twoLevelId,
                                    @RequestParam(value = "goodName", required = false) String goodName,
                                    @RequestParam(value = "goodPrice", required = false) String goodPrice,
                                    @RequestParam(value = "goodColorStock", required = false) String goodColorStock,
                                    @RequestParam(value = "goodPic", required = false) String goodPic,
                                    @RequestParam(value = "goodDesc", required = false) String goodDesc,
                                    HttpServletRequest request) throws IOException {

        ApiResult result = null;

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }

        FxGoodInfo fxGoodInfo = new FxGoodInfo();
        fxGoodInfo.setGoodColorStock(goodColorStock);
        fxGoodInfo.setGoodCreateTime(DateUtil.getYMDHMSDate());
        fxGoodInfo.setGoodDesc(goodDesc);
        fxGoodInfo.setGoodName(goodName);
        fxGoodInfo.setGoodPic(goodPic);
        fxGoodInfo.setGoodState("1");
        fxGoodInfo.setGoodColorStock(goodColorStock);
        fxGoodInfo.setGoodPrice(new BigDecimal(goodPrice));
        fxGoodInfo.setOneLevelId(Integer.parseInt(oneLevelId));
        fxGoodInfo.setTwoLevelId(Integer.parseInt(twoLevelId));
        fxGoodInfo.setLoginUserId(to.getData().toString());

        Integer success = this.fxGoodInfoService.addFxGoodInfo(fxGoodInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "获取待审核分销商品记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "oneLevelId", value = "一级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "twoLevelId", value = "二级菜单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodName", value = "商品名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "beginPrice", value = "开始价格", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "endPrice", value = "截止价格", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "endTime", value = "截止时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodState", value = "商品状态(1:待审核，2:已发布，3：拒绝发布)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "时间节点(1:当天,2:历史)", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/getFxGoodRecordByGoodState", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxGoodRecordByGoodState( @RequestParam(value = "oneLevelId", required = false) String oneLevelId,
                                    @RequestParam(value = "twoLevelId", required = false) String twoLevelId,
                                    @RequestParam(value = "goodName", required = false) String goodName,
                                    @RequestParam(value = "beginPrice", required = false) String beginPrice,
                                    @RequestParam(value = "endPrice", required = false) String endPrice,
                                    @RequestParam(value = "beginTime", required = false) String beginTime,
                                    @RequestParam(value = "endTime", required = false) String endTime,
                                    @RequestParam(value = "goodState", required = false) String goodState,
                                    @RequestParam(value = "type", required = false) String type) throws IOException {

        ApiResult result = null;

        String nowSDate = null;
        String nowEDate = null;
        String historyDate = null;
        if("1".equals(type)){
            nowSDate = DateUtil.getYMDDate()+"00:00:00";
            nowEDate = DateUtil.getYMDDate()+"23:59:59";
        }else if("2".equals(type)){
            historyDate = DateUtil.getYMDDate()+"00:00:00";
        }

        List<Map> list = this.fxGoodInfoService.getFxGoodRecordByGoodState(oneLevelId,twoLevelId,goodName,beginPrice,endPrice,beginTime,endTime,goodState,nowSDate,nowEDate,historyDate);

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, null);

        return  result;
    }

    @ApiOperation(value = "对待审核分销商品操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "type", value = "操作(1:同意,2:拒绝)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "remark", value = "备注", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品id", required = false, dataType = "String")

    })
    @RequestMapping(value = "/updateFxGoodInfoToPassOrCancel", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updateFxGoodInfoToPassOrCancel( @RequestParam(value = "type", required = false) String type,
                                                 @RequestParam(value = "remark", required = false) String remark,
                                                 @RequestParam(value = "goodId", required = false) String goodId) throws IOException {

        ApiResult result = null;

        FxGoodInfo fxGoodInfo = new FxGoodInfo();
        fxGoodInfo.setGoodId(Integer.parseInt(goodId));
        fxGoodInfo.setRemark(remark);

        if("1".equals(type)){
            fxGoodInfo.setGoodState("2");
        }else if("2".equals(type)){
            fxGoodInfo.setGoodState("3");
        }

        Integer success = this.fxGoodInfoService.updateFxGoodInfo(fxGoodInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "查询客户端所有分销商品")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "levelName", value = "类别名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "endTime", value = "截止时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodName", value = "商品名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "loginUserId", value = "商品名称", required = false, dataType = "String")

    })
    @RequestMapping(value = "/getAllFxGoodInfoByUser", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllFxGoodInfoByUser( @RequestParam(value = "beginTime", required = false) String beginTime,
                                             @RequestParam(value = "levelName", required = false) String levelName,
                                             @RequestParam(value = "endTime", required = false) String endTime,
                                             @RequestParam(value = "goodName", required = false) String goodName,
                                             HttpServletRequest request) throws IOException {

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }
        String loginUserId = (String)to.getData();
        List<Map> list = this.fxGoodInfoService.getAllFxGoodInfoByUser(beginTime,endTime,goodName,loginUserId,levelName);
        return  new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, null);
    }

    @ApiOperation(value = "删除客户端分销商品")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品id", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/deleteFxGoodInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult deleteFxGoodInfo( @RequestParam(value = "goodId", required = false) String goodId) throws IOException {

        ApiResult result = null;

        Integer success = this.fxGoodInfoService.deleteFxGoodInfo(goodId);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "获取分销商品首页商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodName", value = "商品名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "levelName", value = "类别名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "类型(1:最新,2:全部)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "当页记录", required = false, dataType = "Integer")

    })
    @RequestMapping(value = "/getFxIndexGoodInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxIndexGoodInfo( @RequestParam(value = "goodName", required = false) String goodName,
                                         @RequestParam(value = "levelName", required = false) String levelName,
                                         @RequestParam(value = "type", required = false) String type,
                                         @RequestParam(value = "current", required = false) Integer current,
                                         @RequestParam(value = "pageSize", required = false) Integer pageSize) throws IOException {

        ApiResult result = null;

        PageHelper.startPage(Integer.valueOf(current), Integer.valueOf(pageSize));
        List<Map> list = null;
        String beginTime = null;
        String endTime = null;

        if("1".equals(type)){
            beginTime = DateUtil.getYMDDate()+" 00:00:00";
            endTime = DateUtil.getYMDDate()+" 23:59:59";
            list = this.fxGoodInfoService.getFxIndexGoodInfo(goodName,levelName,beginTime,endTime);

        }else if("2".equals(type)){
            list = this.fxGoodInfoService.getFxIndexGoodInfo(goodName,levelName,beginTime,endTime);

        }

        //获取分页信息
        PageInfo<Map> pageInfo = new PageInfo<Map>(list);
        RdPage rdPage = RdPage.getPageInfo(pageInfo, String.valueOf(current), String.valueOf(pageSize));

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, rdPage);

        return  result;
    }


    @ApiOperation(value = "获取分销商品详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品id", required = false, dataType = "String"),
    })
    @RequestMapping(value = "/getDetailFxGoodInfoByGoodId", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getDetailFxGoodInfoByGoodId( @RequestParam(value = "goodId", required = false) String goodId) throws IOException {

        ApiResult result = null;

        Map<String,Object> map = this.fxGoodInfoService.getDetailFxGoodInfoByGoodId(goodId);

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", map, null);

        return  result;
    }


    @ApiOperation(value = "新增分销商品订单")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "fxOrderGoodId", value = "分销商品id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderReceiveId", value = "收获信息id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderInUserId", value = "分销用户id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderSkuNumber", value = "订单sku和数量，(红色_1,黑色_2)", required = false, dataType = "String"),


    })
    @RequestMapping(value = "/addNewFxOrderInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult addNewFxOrderInfo( @RequestParam(value = "fxOrderGoodId", required = false) String fxOrderGoodId,
                                        @RequestParam(value = "fxOrderReceiveId", required = false) String fxOrderReceiveId,
                                        @RequestParam(value = "fxOrderInUserId", required = false) String fxOrderInUserId,
                                        @RequestParam(value = "fxOrderSkuNumber", required = false) String fxOrderSkuNumber) throws IOException {

        ApiResult result = null;

        FxOrderInfo fxOrderInfo = new FxOrderInfo();
        fxOrderInfo.setFxOrderId("FX"+DateUtil.getTimeId());
        fxOrderInfo.setFxOrderCreateTime(DateUtil.getYMDHMSDate());
        fxOrderInfo.setFxOrderGoodId(Integer.valueOf(fxOrderGoodId));
        fxOrderInfo.setFxOrderInUserId(fxOrderInUserId);
        fxOrderInfo.setFxOrderReceiveId(Integer.valueOf(fxOrderReceiveId));
        fxOrderInfo.setFxOrderSkuNumber(fxOrderSkuNumber);
        fxOrderInfo.setFxOrderState("1");

        Integer success = this.fxOrderInfoService.addNewFxOrderInfo(fxOrderInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }
        return  result;
    }


    @ApiOperation(value = "查询不同状态分销订单状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "endTime", value = "截止时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "userName", value = "下单用户", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodName", value = "商品名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderState", value = "分销订单状态,(1:未支付,2:已下单,3:已发货,4:驳回)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "当页记录", required = false, dataType = "Integer")



    })
    @RequestMapping(value = "/getFxOrderInfoByState", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxOrderInfoByState(@RequestParam(value = "beginTime", required = false) String beginTime,
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                           @RequestParam(value = "userName", required = false) String userName,
                                           @RequestParam(value = "goodName", required = false) String goodName,
                                           @RequestParam(value = "fxOrderState", required = false) String fxOrderState,
                                           @RequestParam(value = "current", required = false) Integer current,
                                           @RequestParam(value = "pageSize", required = false) Integer pageSize, HttpServletRequest request) throws IOException {

        ApiResult result = null;

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }

        PageHelper.startPage(Integer.valueOf(current), Integer.valueOf(pageSize));

        List<Map> list = this.fxOrderInfoService.getFxOrderInfoByState(to.getData().toString(),beginTime,  endTime,  userName,  goodName, fxOrderState);

        //获取分页信息
        PageInfo<Map> pageInfo = new PageInfo<Map>(list);
        RdPage rdPage = RdPage.getPageInfo(pageInfo, String.valueOf(current), String.valueOf(pageSize));

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, rdPage);

        return  result;
    }


    @ApiOperation(value = "分销订单的操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "type", value = "操作类型(1:支付,2:确认处理,3:驳回)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderId", value = "分销订单id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderCancelReason", value = "分销订单驳回原因", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "logisticsOrder", value = "物流订单号", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "logisticsName", value = "物流名称", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/handleFxOrderInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult handleFxOrderInfo( @RequestParam(value = "type", required = false) String type,
                                            @RequestParam(value = "fxOrderId", required = false) String fxOrderId,
                                            @RequestParam(value = "fxOrderCancelReason", required = false)String fxOrderCancelReason,
                                            @RequestParam(value = "logisticsOrder", required = false) String logisticsOrder,
                                            @RequestParam(value = "logisticsName", required = false) String logisticsName) throws IOException {

        ApiResult result = null;

        FxOrderInfo fxOrderInfo = new FxOrderInfo();
        fxOrderInfo.setFxOrderId(fxOrderId);
        if(logisticsOrder != null && logisticsName != null){
            fxOrderInfo.setFxOrderLogisticsName(logisticsName);
            fxOrderInfo.setFxOrderLogisticsOrder(logisticsOrder);
        }

        Integer success = this.fxOrderInfoService.updateFxOrderInfo(type,fxOrderCancelReason,fxOrderInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "个人分销列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "endTime", value = "截至时间", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderRecordType", value = "类型（1：收入，2：提现）", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "fxOrderRecorderStatus", value = "提现记录类型（1：未处理，2：已处理）", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "页面记录数", required = false, dataType = "Integer")
    })
    @RequestMapping(value = "/getFxOrderRecord", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxOrderRecord( @RequestParam(value = "beginTime", required = false) String beginTime,
                                       @RequestParam(value = "endTime", required = false) String endTime,
                                       @RequestParam(value = "fxOrderRecordType", required = false) String fxOrderRecordType,
                                       @RequestParam(value = "fxOrderRecorderStatus", required = false) String fxOrderRecorderStatus,
                                       @RequestParam(value = "current", required = false) Integer current,
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize) throws IOException {

        ApiResult result = null;

        PageHelper.startPage(current,pageSize);

        List<Map> list = this.fxOrderInfoService.getFxOrderRecord(beginTime,endTime,fxOrderRecordType,fxOrderRecorderStatus);

        //获取分页信息
        PageInfo<Map> pageInfo = new PageInfo<Map>(list);
        RdPage rdPage = RdPage.getPageInfo(pageInfo, String.valueOf(current), String.valueOf(pageSize));

        result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, rdPage);

        return  result;
    }

    @ApiOperation(value = "个人分销记录操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "txMoney", value = "提现金额", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "txType", value = "提现种类（1：支付宝，2：微信）", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "txAccount", value = "提现账号", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "userId", value = "提现账号", required = false, dataType = "String")

    })
    @RequestMapping(value = "/updFxOrderMoneyTX", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updFxOrderMoneyTX(@RequestParam(value = "txMoney", required = false) String txMoney,
                                       @RequestParam(value = "txType", required = false) String txType,
                                       @RequestParam(value = "txAccount", required = false) String txAccount,
                                       @RequestParam(value = "userId", required = false) String userId) throws IOException {

        ApiResult result = null;

        FxOrderRecord fxOrderRecord = new FxOrderRecord();
        fxOrderRecord.setForState("2");
        fxOrderRecord.setForRemark("提现");
        fxOrderRecord.setForOrderOutMoney(txMoney);
        fxOrderRecord.setForOrderOutType(txType);
        fxOrderRecord.setForOrderAccount(txAccount);
        fxOrderRecord.setForCreateTime(DateUtil.getYMDHMSDate());
        fxOrderRecord.setForOrderStatus("1");

        Integer success = this.fxOrderInfoService.updFxOrderMoneyTX(fxOrderRecord,userId);


        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "提现订单处理操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "forId", value = "提现记录订单id", required = false, dataType = "String")
    })
    @RequestMapping(value = "/updFxOrderDeal", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updFxOrderDeal( @RequestParam(value = "forId", required = false) String forId) throws IOException {

        ApiResult result = null;

        FxOrderRecord fxOrderRecord = new FxOrderRecord();
        fxOrderRecord.setForOrderStatus("2");
        fxOrderRecord.setForId(forId);
        String userId = null;

        Integer success = this.fxOrderInfoService.updFxOrderMoneyTX(fxOrderRecord,userId);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "订单收获地址操作")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "type", value = "操作（1：新增，2：删除，3：查询）", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "receiveName", value = "收获人姓名", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "receiveCountry", value = "收获城市", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "receiveAddress", value = "收获地址", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "receivePhone", value = "收获人电话", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "receivePostcode", value = "收获邮编", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "receiveId", value = "收获信息id", required = false, dataType = "String")

    })
    @RequestMapping(value = "/handleReceiveInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult handleReceiveInfo( @RequestParam(value = "type", required = false) String type,
                                        @RequestParam(value = "receiveName", required = false) String receiveName,
                                        @RequestParam(value = "receiveCountry", required = false) String receiveCountry,
                                        @RequestParam(value = "receiveAddress", required = false) String receiveAddress,
                                        @RequestParam(value = "receivePhone", required = false) String receivePhone,
                                        @RequestParam(value = "receivePostcode", required = false) String receivePostcode,
                                        @RequestParam(value = "receiveId", required = false) String receiveId,
                                        HttpServletRequest request) throws IOException {

        ApiResult result = null;
        Integer success = null;

        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }

        if("3".equals(type)){

            List<Map> list = this.fxReceiveInfoService.getAllReceiveInfo(to.getData().toString());
            return new  ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, null);

        }else if("1".equals(type)){

            success = this.fxReceiveInfoService.addReceiveInfo(receiveName,receiveCountry,receiveAddress,receivePhone,receivePostcode,to.getData().toString());

        }else if("2".equals(type)){

            success = this.fxReceiveInfoService.deleteReceiveInfo(receiveId);

        }

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "修改密码")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "userId", value = "用户id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "password", value = "用户id", required = false, dataType = "String")

    })
    @RequestMapping(value = "/updUserPassword", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updUserPassword( @RequestParam(value = "userId", required = false) String userId,
                                      @RequestParam(value = "password", required = false) String password) throws IOException {

        ApiResult result = null;

        FxUserInfo fxUserInfo = new FxUserInfo();
        fxUserInfo.setUserId(Integer.parseInt(userId));
        fxUserInfo.setUserPassward(password);

        Integer success = this.fxUserService.updateFxUserInfo(fxUserInfo);

        if (success == 1) {
            result = new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", null, null);
        } else {
            result = new ApiResult(Constant.FAIL_CODE_VALUE, "失败", null, null);
        }

        return  result;
    }


    @ApiOperation(value = "用户管理")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "username", value = "用户名", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "phone", value = "号码", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "记录数", required = false, dataType = "Integer")
    })
    @RequestMapping(value = "/getAllUserInfoList", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllUserInfoList(String username,String phone,int current,int pageSize,HttpServletRequest request) throws IOException {
        /*String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }*/

        PageHelper.startPage(current,pageSize);

        List<Map> list = this.fxUserService.getAllUserInfoList(username,phone);

        //获取分页信息
        PageInfo<Map> pageInfo = new PageInfo<Map>(list);
        RdPage rdPage = RdPage.getPageInfo(pageInfo, String.valueOf(current), String.valueOf(pageSize));

        return new ApiResult(Constant.SUCCEED_CODE_VALUE, "成功", list, rdPage);

    }


    @ApiOperation(value = "判断该erp用户是否是分销商户拥有分销商品的权限")
    @ApiImplicitParams({
    })
    @RequestMapping(value = "/getFxGoodPowerByErpUser", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFxGoodPowerByErpUser(HttpServletRequest request) throws IOException {
        String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }

        Integer success = this.fxUserService.getFxGoodPowerByErpUser(to.getData().toString());
        return  new ApiResult(success != null && success >= 1);
    }


    @ApiOperation(value = "更改用户角色或密码")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "用户id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "roleId", value = "角色id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "delFlag", value = "0启用，1禁用", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "password", value = "密码", required = false, dataType = "Integer"),
    })
    @RequestMapping(value = "/updUserRoleOrPassword", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updUserRoleOrPassword(String id,String roleId,Integer delFlag,String password,HttpServletRequest request) throws IOException {
        /*String token = request.getHeader("token");
        ApiResult to = loginService.checkToken(token);
        if (to.getCode() != 200) {
            return to;
        }*/

        Integer success = this.fxUserService.updUserRoleOrPassword(id,roleId,delFlag,password);

        return  new ApiResult(success != null && success >= 1);

    }
}
